<?xml version="1.0" encoding="UTF-8" ?>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"
    import="org.uni.cil.controller.Controller,org.uni.cil.tester.*,java.util.*" 
    %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="EN" lang="EN" dir="ltr">
<head profile="http://gmpg.org/xfn/11">
<title>CIL |  MailToCrm</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta http-equiv="imagetoolbar" content="no" />
<link rel="stylesheet" href="styles/layout.css" type="text/css" />
</head>
<body id="top">
<div class="wrapper row1">
  <div id="header" class="clear">
    <div class="fl_left">
      <h1><a href="index.jsp">Cloud Information Logistics</a></h1>
      <p>MailToCRM</p>
    </div>
  </div>
</div>
<!-- ####################################################################################################### -->
<div class="wrapper row2">
  <div class="rnd">
    <!-- ###### -->
    <div id="topnav">
      <ul>
        <li><a href="index.jsp">Search</a></li>
      </ul>
    </div>
    <!-- ###### -->
  </div>
</div>
<!-- ####################################################################################################### -->
<div class="wrapper row3">
  <div class="rnd">
    <div id="container" class="clear">
      <!-- ####################################################################################################### -->
      <h1>Search your mails and transfer them to your CRM-System</h1>
		<div class="imgholder"><img src="images/crmLogo.png" alt="" /></div>
		<h1>Ergebnisse</h1>
		<div>
		<table border="3">
		<tr><th>Nr.</th><th>Mail</th><th>Size</th><th>Time</th><th>Upload</th></tr>
			<% 
			HashMap<String, String> connectionData = new HashMap<String, String> ();
			
			String mailProvider = request.getParameter("MailSystem");
			TestCase testCase = null;
			String crmProvider = request.getParameter("CRMSystem");
			String ssl = request.getParameter("ssl");
			if (crmProvider == null || TestCase.crmProvider.valueOf(crmProvider)==null) {
				out.write("<font color='red'>Please choose a valid CRM-System Provider</font>");
			}else{
				if (mailProvider == null || mailProvider.length() == 0) {
					String[] params = new String[] {"username", "password", "hostname", "hosttype"};
					for (int i = 0; i < params.length; i++)
					{
						connectionData.put(params[i], request.getParameter(params[i]));
					}
					boolean useSSL = false;
					if (ssl == "true") {
						useSSL = true;
					}
					
						testCase = new TestCase(connectionData, TestCase.crmProvider.valueOf(crmProvider), false, useSSL);	
				}
				else {
					testCase = new TestCase(TestCase.mailProvider.valueOf(mailProvider), TestCase.crmProvider.valueOf(crmProvider), false);	
				}
				
				String[] searchToken = request.getParameterValues("searchTerm");
				String[] searchText = request.getParameterValues("searchText");
				testCase.setSearch(searchToken, searchText);
				Tester.main(out, testCase);
			}
			%>	
		</table>
     	</div>
      <!-- ####################################################################################################### -->
    </div>
  </div>
</div>
<!-- ####################################################################################################### -->
<div class="wrapper row4">
  <div class="rnd">
    <div id="footer" class="clear">
      <!-- ####################################################################################################### -->
      <div class="fl_left clear">
        Check your upload:
      </div>
      <div class="fl_right">
        <div class="clear">
           <a style="background-position:0 0;" href="https://piademos.cas.de/pia/login" target="_blank"><img src="images/cas_pia_logo.png" alt="" /></a>
        </div>
      </div>
      <!-- ####################################################################################################### -->
    </div>
  </div>
</div>
<!-- ####################################################################################################### -->
<div class="wrapper">
  <div id="copyright" class="clear">
    <p class="fl_left">Sebastian Schäpertöns - Elmar Jakobs - Christian Pfeffer </p>
    <p class="fl_right">Template by <a href="http://www.os-templates.com/" title="Free Website Templates">OS Templates</a></p>
  </div>
</div>
</body>
</html>